
Imports std
Imports System.IO

Module hexmore

    Public Const maxReadATime As Int32 = 512

    Public Function arround(ByRef str As String) As String
        Dim rtn As String = str
        While strlen(rtn) < 2
            rtn = character._0 + rtn
        End While
        rtn = character._0 + character.x + rtn

        Return rtn
    End Function

    Sub Main(ByVal args() As String)
        On Error Resume Next
        Dim istream As FileStream = Nothing
        Dim i As Int32
        Dim input As Int32

        If args.Length < 1 Then
            raiseError("argument count error, input", errorHandle.errorType.critical)
        Else
            istream = New FileStream(args(0), FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
            assert(Not istream Is Nothing, "file no found, " + args(0))
            While True
                For i = 1 To maxReadATime
                    If istream.Position = istream.Length Then
                        Exit While
                    Else
                        input = istream.ReadByte()
                        Console.Write(arround(Convert.ToString(input, 16)) + character.blank)
                    End If
                Next
                pause()
            End While
        End If
    End Sub

End Module
